﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HGZP.BLL;
using HGZP.Model;
using System.Data;

namespace SZCB.admin.Contry
{
    public partial class ContryManager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                ViewState["wheresql"] = "";
                GetContentCount();
                BindContentData();

            }

        }

        #region 绑定内容表单()
        private void GetContentCount()
        {
            string sql = " ";
            if (ViewState["wheresql"] != null)
                sql += ViewState["wheresql"].ToString();
            CCountryBLL myCCountryBLL = new CCountryBLL();
            returnDataPager.RecordCount = myCCountryBLL.F09_GetCount(sql);
        }
        private void BindContentData()
        {
            string sql = " ";
            if (ViewState["wheresql"] != null)
                sql += ViewState["wheresql"].ToString();
            CCountryBLL myCCountryBLL = new CCountryBLL();
            RptData.DataSource = myCCountryBLL.F08_SelectColumnHaveWhereOrder_OnePage(returnDataPager.StartRecordIndex - 1, returnDataPager.PageSize, "*", sql, "");
            RptData.DataBind();
        }
        protected void ReturnDataPagerPageChanged(object sender, EventArgs e)
        {
            BindContentData();
        }
        #endregion



        protected void RptData_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {

                Repeater rp = e.Item.FindControl("Repeater1") as Repeater;
                CProvinceBLL myCProvinceBLL = new CProvinceBLL();
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                rp.DataSource = myCProvinceBLL.F02_SelectHaveWhere("sCountryGuid='" + rowv["sGuid"].ToString() + "'");
                rp.DataBind();
            }

        }


        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {

                Repeater rp = e.Item.FindControl("Repeater2") as Repeater;
                CCityBLL myCCityBLL = new CCityBLL();
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                rp.DataSource = myCCityBLL.F02_SelectHaveWhere("sProvinceGuid='" + rowv["sGuid"].ToString() + "'");
                rp.DataBind();
            }

        }

    }
}